<template>
	<view class="box" @tap.prevent="zcInputValue1">
		<view class="banner-wrap f-side">
			<navigator url="../home_changStore/home_changStore" class="iconfont icon-xiasanjiaoxiangxiamianxing">{{ShopOrganName}}</navigator>
			<view class="flex itemCenter">
				<view @tap="do_clockShow" class="iconfont icon-right icon-xiasanjiaoxiangxiamianxing">{{workStatus}}</view>
				<view class="iconfont icon-sousuo2 " @click="scan('ticket')"></view>
			</view>
		</view>
		<clockIn v-if="clockShow" @do_clockIn="do_clockIn" :workStatus="workStatus" :saleData='saleData'> </clockIn>
		<!-- 选项卡导航 -->
		<view class="content-box">
			<view class="tab-bar flex">
				<block v-for="(item,index) in tabInfo" :key="index">
					<view class="tab-info zcFlex1 flex zcAlignI_center" @tap="do_selectTab(index)" :class="index==selectIndex?tabClass[selectIndex]:''">
						<view class="zcJustifyC_start">
							{{item.name}}
							<view class="tab-number flex f-center" style="padding-right: 20upx;">{{item.number}} <view v-if="item.numberClose||item.numberClose==0">/{{item.numberClose}}</view></view>
						</view>
					</view>
				</block>
			</view>
			<!-- 新加入入场列表查询 -->
			<view class="serach-add content-head flex zcAlignI_center">
				<view class="f-upDonwn" @tap="scan('car')" style="padding-top: 10upx;">
					<image src="../../static/home/car-read-2019-11-29.png" mode=""></image>
					<view class="car-scan">车牌识别</view>
				</view>
				
				<view class="flex add-car-wrap flex1">
					<value class='picker uni-flex zcAlignI_center zcJustifyC_center' mode="selector" @tap="zcCityPicker" >
						<view class='uni-flex zcAlignI_center zcJustifyC_center picker_view'>{{city.value}}</view>
					</value>
					<zc-input  :isShowPicker="isShowPicker" :inputVal="inputValue" @clickInput="zcInputValue" @value="getInputValue" ></zc-input>
					<!-- <input  class="add-input2" style="padding-left: 20upx;" type="text" :focus="isShowPicker" disabled="true" :value="inputValue" placeholder="请输入车牌号" @tap.stop="zcInputValue" /> -->

				</view>

				<!-- <input placeholder-class="input-placeholder" type="text" v-model="carReadResult" class="zcFlex1 " placeholder="请输入车牌号"  /> -->
				<view class="f-center btn-add-wrap"><button type="primary" @tap="do_goNext(carReadResult)">接待</button> </view>
				<view class="f-center btn-add-wrap"><button :disabled="doSearch1" type="primary" @tap="do_QueryEntryCarList" class="add-search">查询</button> </view>
			</view>


			<swiper :duration="0" :current="selectIndex" class="swiper-box" @change="swiperChange">
				<!--  //进场 -->
				<swiper-item class="swiper-item" catchtouchmove="false" >
					<scroll-view v-if="selectIndex==0" scroll-y class="scroll-view" @scrolltoupper="scrolltoupper" @scroll='scrolltolower ' @scrolltolower="do_getMore">
						<block v-for="(item,index) in approachData" :key='index'>
							<homeApproach  :item="item" @do_meeting="do_meeting" @do_showDetail="do_showDetail"></homeApproach>
						</block>
						<!-- 上拉加载 -->
						<view v-show="loadingText" class="uni-tab-bar-loading">
							{{loadingText}}
						</view>
						<!-- 无数据 -->
						<view v-if="approachData.length==0" class="uni-tab-bar-loading" style="text-align: center;">
							<view class="no_model">
								<image src="../../static/no_data.png" mode="widthFix" style="width: 100%;"></image>
								<view class="no_text">暂无数据</view>
							</view>
						</view>
					</scroll-view>
				</swiper-item>
				<!-- //接待 -->
				<swiper-item class="swiper-item" catchtouchmove="false" >
					<scroll-view scroll-y class="scroll-view" 
					v-if="selectIndex==1"
					@scrolltoupper="scrolltoupper" 
					@scroll='scrolltolower ' 
					@scrolltolower="do_getMore">
						<block v-for="(item,index) in mettingData" :key='index'>
							<homeMetting 
							  :item="item" @do_metSubmit="do_metSubmit" @do_showDetail="do_showDetail"></homeMetting>
						</block>
												<!-- 上拉加载 -->
						<view v-show="loadingText" class="uni-tab-bar-loading">
							{{loadingText}}
						</view>
						<view v-if="mettingData.length==0" class="uni-tab-bar-loading" style="text-align: center;">
							<view class="no_model">
								<image src="../../static/no_data.png" mode="widthFix" style="width: 100%;"></image>
								<view class="no_text">暂无数据</view>
							</view>
						</view>
					</scroll-view>
				</swiper-item>
				<!--  //服务中 -->
				<swiper-item class="swiper-item" catchtouchmove="flase">
					<scroll-view v-if="selectIndex==2" scroll-y class="scroll-view" @scrolltoupper="scrolltoupper" @scroll='scrolltolower ' @scrolltolower="do_getMore">
						<block v-for="(item,index) in serviceData" :key='index'>
							<homeService :item="item" @do_service='do_service' @do_showDetail="do_showDetail"></homeService>
						</block>
												<!-- 上拉加载 -->
						<view v-show="loadingText" class="uni-tab-bar-loading">
							{{loadingText}}
						</view>
						<view v-if="serviceData.length==0" class="uni-tab-bar-loading" style="text-align: center;">
							<view class="no_model">
								<image src="../../static/no_data.png" mode="widthFix" style="width: 100%;"></image>
								<view class="no_text">暂无数据</view>
							</view>
						</view>
					</scroll-view>
				</swiper-item>
				<!--  //已交车 -->
				<swiper-item class="swiper-item" catchtouchmove="false">
					<scroll-view v-if="selectIndex==3" scroll-y class="scroll-view" @scrolltoupper="scrolltoupper" @scroll='scrolltolower ' @scrolltolower="do_getMore">
						<block v-for="(item,index) in finishData" :key='index'>
							<homeFinish :item="item" @do_finish="do_finish"></homeFinish>
						</block>
						<!-- 上拉加载 -->
						<view v-show="loadingText" class="uni-tab-bar-loading">
							{{loadingText}}
						</view>
							<view v-if="finishData.length==0" class="uni-tab-bar-loading" style="text-align: center;">
								<view class="no_model">
									<image src="../../static/no_data.png" mode="widthFix" style="width: 100%;"></image>
									<view class="no_text">暂无数据</view>
								</view>
							</view>
					</scroll-view>
				</swiper-item>
			</swiper>
		</view>
		<!-- 展示详细线索 -->
		<view class="show-detail-wrap f-center" v-if="showCommon" @tap="close_showdetail">
			<view class="show-detail-info ">
				<view class="flex"><view style="color:#A0A0A0;margin-right: 10upx;">项目名称:</view>{{showCommonData.Name}}</view>
				<view class="flex"><view style="color:#A0A0A0;margin-right: 10upx;">到期时间:</view>{{showCommonData.ExpireDate}}</view>
			</view>
		</view>
		
		<!-- 车牌选择 -->
				<zc-custom-picker @tap="zcInputValue1" :isShowBox1="city.isShowBox1" :zcPickerValue="city.value" @cpConfirm="cpConfirm" @cpCancel="cpCancel" ></zc-custom-picker>

	</view>
</template>

<script>
	let _this
	import clockIn from '../../components/home/home-clock-in.vue'
	import homeApproach from '../../components/home/home-approach.vue'
	import homeMetting from '../../components/home/home-metting.vue'
	import homeService from '../../components/home/home-service.vue'
	import homeFinish from '../../components/home/home-finish.vue'
		import zcCustomPicker from '../../components/zcCustom_picker/zcCustom-picker.vue';
		import zcInput from "../../components/zc-upPhoto/zc-input.vue"
	export default {
		components: {
			clockIn, //打卡
			homeApproach, //进场
			homeMetting, //接待
			homeService, //服务中
			homeFinish, //已交车
			zcCustomPicker,
			zcInput
		},
		data() {
			return {
				showCommonData:{},//线索详情
				showCommon:false, //显示线索详情
				workStatus: '上班',
				carReadResult: '', //车牌识别结果
				carWriteResult: '', //车牌输入查询
				scanResult: '', //扫一扫结果
				linkShow: true, //链接线是否显示
				clockShow: false,
				tabClass: ["tabColor1", "tabColor2", "tabColor3", "tabColor4"],
				carInfoSelect: {
					"0": "进场",
					"1": "接待",
					"2": "服务中",
					"3": "已交车"
				},
				bgImg: '../../static/home/bg.png',
				tabInfo: [{
						name: "进场",
						number: '0'
					},
					{
						name: "接待/终止",
						number: '0'
					},
					{
						name: "服务中",
						number: '0'
					},
					{
						name: "已交车",
						number: '0'
					}
				],
				approachData: [], //进场
				finishData: [], //已交车
				mettingData: [], //接待
				serviceData: [], //服务
				selectIndex: 0,
				saleData: {}, //打卡信息里面数据
				maskData:{
					list1:['港','澳','学','警','领','使'],
					list2:['1','2','3','4','5','6','7','8','9','0'],
					list3:['Q','W','E','R','T','Y','U','I','O','P'],
					list4:['A','S','D','F','G','H','J','K','L'],
					list5:['Z','X','C','V','B','N','M']
				},
				city:{
					value:'川',
					isShowBox1:false
				},
				isShowPicker:false,
				inputValue:'', //车牌后半部分
				loadingText:''   ,//上拉加载数据
				pages:10,	// 每页 显示多少条数据
				pageIndex0:0,	// 当前数据开始数据是第几条
				pageIndex1:0,	// 当前数据开始数据是第几条
				pageIndex2:0,	// 当前数据开始数据是第几条
				pageIndex3:0,	// 当前数据开始数据是第几条
				dataLength0:0,	// 当前数据返回个数
				dataLength1:0,	// 当前数据返回个数
				dataLength2:0,	// 当前数据返回个数
				dataLength3:0,	// 当前数据返回个数
				doSearch:false  ,//知否禁止查询按钮
				firstInit:true  ,//是否第一次加载页面
				ShopOrganName:'精诚汽车武侯店'

			}
		},
		onLoad() {
			_this = this;
      _this.initHome(0,0);
			console.log("onLoda");
		},
		onShow(){
			console.log("onShow");
			if(!_this.firstInit){
				_this.initHome(_this.selectIndex,0);
			}
			_this.firstInit = false
		},
		methods: {
			initHome(index){//index 处于nav索引
				_this.getSaleManHome(); //首页信息
				_this.getSaleManLineOn(); //上班打卡情况
				_this.inputValue = "";
				let doGetData ={
					0:_this.approachData,
					1:_this.mettingData,
					2:_this.serviceData,
					3:_this.finishData,
				} ;
				_this.pageIndex0 = 0;
				_this.pageIndex1 = 0;
				_this.pageIndex2 = 0;
				_this.pageIndex3 = 0;
				_this.QueryEntryCarList(index||0,0); //进场列表查询

			},
			/* 上拉加载跟多 分四种情况*/
			do_getMore(){
					let _moreIndex={
					0:{dataLength:_this.dataLength0,pageIndex:_this.pageIndex0},
					1:{dataLength:_this.dataLength1,pageIndex:_this.pageIndex1},
					2:{dataLength:_this.dataLength2,pageIndex:_this.pageIndex2},
					3:{dataLength:_this.dataLength3,pageIndex:_this.pageIndex3}
				}
			if (_moreIndex[_this.selectIndex].dataLength<_this.pages) {
				_this.loadingText = '没有更多了...';
					return;
				}
				_this.loadingText = '加载中';
				_this.QueryEntryCarList(_this.selectIndex,_moreIndex[_this.selectIndex].pageIndex,_moreIndex[_this.selectIndex].dataLength)
			},
			/* 车牌输入 */
			zcCityPicker() {
				// console.log('打开弹出层');
				_this.city.isShowBox1 = true;
			},
				cpConfirm(res) {
				// console.log('子组件参数 = ',res);
				_this.city.value = res;
				_this.city.isShowBox1 = false;
			},
			//  初始化  车牌地区简称  弹出层
			cpCancel() {
				_this.city.isShowBox1 = false;
			},
			// zcInputValue(res) {
			// 	_this.isShowPicker = !_this.isShowPicker;
			// 	console.log(3);
			// },
			zcInputValue1() {
				_this.isShowPicker = false;
				console.log('关闭车牌输入');
			},
			getInputValue(res) {    //  获取输入框值
			console.log("输入框值",res);
			    _this.inputValue = res;
			},
			zcInputValue() {  //  点击输入框事件
			    _this.isShowPicker = true;
			},
			
			zcTouchmove() {
				return
			},
						//  车牌输入 软键盘事件
			clickChange(res) {
				if (!_this.inputValue) {
					_this.inputValue = res;
				}else{
					_this.inputValue = _this.inputValue+res;
				}
			},
			itemDel(res) {
				_this.inputValue = res.substring(0,res.length-1);
			},
			/* 显示线索详情 */
			do_showDetail(item){
				if(item){
					_this.showCommon = true;
					_this.showCommonData = item;
				}
			},
			close_showdetail(){
				_this.showCommon = false
			},
			/* 服务里面终止 */
			doFinish_Repair(sn) { //服务终止
				_this.$ZcPublic.Server.Post({
					IsNeedLogin: false,
					Paras: {
						Name: 'Uni_Partner_Detail',
						Action: 'doFinish_Repair',
						data: {
							SN: sn
						}
					},
					Callback: _this.cb_doFinish_Repair,
					Scope: _this
				})
			},
			cb_doFinish_Repair(resJson, scope) {
					console.log("车辆交车结果", resJson)
					if (resJson.success) {
						uni.showToast({
							title: '交车成功！'
						});
						_this.initHome(_this.selectIndex);
					} else {
						uni.showModal({
							title: '温馨提示',
							content: resJson.msg,
							showCancel: false
						})
					}
			},
			doCancel_Repair(sn) { //服务交车
				_this.$ZcPublic.Server.Post({
					IsNeedLogin: false,
					Paras: {
						Name: 'Uni_Partner_Detail',
						Action: 'doCancel_Repair',
						data: {
							SN: sn
						}
					},
					Callback: _this.cb_doCancel_Repair,
					Scope: _this
				})
			},
			cb_doCancel_Repair(resJson, scope) {
					console.log("车辆服务终止结果", resJson)
					if (resJson.success) {
						uni.showToast({
							title: '服务终止成功！'
						});
						_this.initHome(_this.selectIndex);
					} else {
						uni.showModal({
							title: '温馨提示',
							content: resJson.msg,
							showCancel: false
						})
					}
			},
			do_QueryEntryCarList(){	
					_this.isShowPicker = false
				uni.showLoading({
					title: '加载中',
					mask: true
				});
				_this.pageIndex0 = 0;
				_this.pageIndex1 = 0;
				_this.pageIndex2 = 0;
				_this.pageIndex3 = 0;
				let _moreIndex={
					0:{dataLength:_this.dataLength0,pageIndex:_this.pageIndex0},
					1:{dataLength:_this.dataLength1,pageIndex:_this.pageIndex1},
					2:{dataLength:_this.dataLength2,pageIndex:_this.pageIndex2},
					3:{dataLength:_this.dataLength3,pageIndex:_this.pageIndex3}
				};
				_this.doSearch = true;
				console.log('_moreIndex[_this.selectIndex].pageIndex',_moreIndex[_this.selectIndex].pageIndex);
				_this.QueryEntryCarList(_this.selectIndex,_moreIndex[_this.selectIndex].pageIndex)
			},
			/*  //查询车辆 0进场列表,1接待列表，2服务列表，3交车列表 参数index:导航选择第几个,indexMore导航对应的当前是第几条
			* dataLength：最后一次回来了几条数据
			* */
			
			QueryEntryCarList(index,indexMore,dataLength) { 
			if(_this.inputValue){
					_this.carReadResult = _this.city.value +_this.inputValue
			}else{
				_this.carReadResult = ""
			}
				let _anctionList = {
					"0": "QueryEntryCarList",
					"1": "QueryReceptCarList",
					"2": "QueryRepairCarList",
					"3": "QueryFinishCar_DayList"
				}
				_this.$ZcPublic.Server.Post({
					IsNeedLogin: false,
					Paras: {
						Name: 'Uni_Partner_Detail',
						Action: _anctionList[index],
						Data:{
							search:_this.carReadResult,
							PageIndex:indexMore,
							Pages:_this.pages
						}						
					},
					Callback: _this.cb_QueryEntryCarList,
					Scope: _this
				})
			},
			cb_QueryEntryCarList(resJson, scope) {
					console.log("车辆所有列表查询结果", resJson)
					if (resJson.success) {
						if (resJson.data.length>0) {
							console.log('_this.selectIndex', _this.selectIndex);
							let _moreIndex={
								0:{dataLength:_this.dataLength0,pageIndex:_this.pageIndex0},
								1:{dataLength:_this.dataLength1,pageIndex:_this.pageIndex1},
								2:{dataLength:_this.dataLength2,pageIndex:_this.pageIndex2},
								3:{dataLength:_this.dataLength3,pageIndex:_this.pageIndex3}
							};
								if (_moreIndex[_this.selectIndex].dataLength < _this.pages) {
									if (_moreIndex[_this.selectIndex].pageIndex >= _this.pages) {
										_this.loadingText = '没有更多了...';
									}else{
										_this.loadingText = '';
									}
								}else {
									_this.loadingText = '加载更多';
								}
								resJson.data.forEach((item)=>{
									if(item.item instanceof Array &&item.item){
										item.item.forEach((item2)=>{
												item2.ExpireDate = this.$ZcPublic.formatDate(item2.ExpireDate, 'yyyy-MM-dd');
										})
									}
								})
							switch (_this.selectIndex) {
								case 0:
									resJson.data.forEach((item) => {
										item.EntryDate = _this.$ZcPublic.formatDate(item.EntryDate, 'yyyy-MM-dd hh:mm:ss');
									});
									if(_this.pageIndex0 == 0){
										_this.approachData = resJson.data
										_this.loadingText = '';
									}else{
											_this.approachData =_this.approachData?[..._this.approachData,...resJson.data]:resJson.data ;
									}
									_this.dataLength0 = resJson.data.length;
									_this.pageIndex0 = _this.pageIndex0+resJson.data.length;	// 初始化 下次加载开始下标
									console.log('_this.approachData', _this.approachData);
									break;
								case 1:
									resJson.data.forEach((item) => {
										item.ReceptionDate = _this.$ZcPublic.formatDate(item.ReceptionDate, 'yyyy-MM-dd hh:mm:ss');
									});
									if(_this.pageIndex1 == 0){
										_this.mettingData = resJson.data
										_this.loadingText = '';
									}else{
									  _this.mettingData = _this.mettingData ? [..._this.mettingData , ...resJson.data] : resJson.data ;
									}
									
									_this.dataLength1 = resJson.data.length;
									_this.pageIndex1 = _this.pageIndex1 + resJson.data.length;	// 初始化 下次加载开始下标
									break;
								case 2:
									resJson.data.forEach((item) => {
										item.RepairDate = _this.$ZcPublic.formatDate(item.RepairDate, 'yyyy-MM-dd hh:mm:ss');
									});
									
									if(_this.pageIndex2 == 0){
										_this.serviceData = resJson.data;
										_this.loadingText = '';
									}else{
									  _this.serviceData =_this.serviceData?[..._this.serviceData,...resJson.data]:resJson.data ;
									}	
										_this.dataLength2 = resJson.data.length;
									_this.pageIndex2 = _this.pageIndex2+resJson.data.length;	// 初始化 下次加载开始下标
									break;
								case 3:
									resJson.data.forEach((item) => {
										item.FinishDate = _this.$ZcPublic.formatDate(item.FinishDate, 'yyyy-MM-dd hh:mm:ss')
									});
									if(_this.pageIndex3 == 0){
										_this.finishData = resJson.data;
										_this.loadingText = '';
									}else{
									  _this.finishData = _this.finishData ? [..._this.finishData,...resJson.data]:resJson.data ;
									}		
									_this.dataLength3 = resJson.data.length;
									_this.pageIndex3 = _this.pageIndex3+resJson.data.length;	// 初始化 下次加载开始下标
									break;
							}
							_this.doSearch = false;
							uni.hideLoading();

						}else{
							_this.loadingText = '';
							switch(_this.selectIndex){
								case  0 :
								if(_this.pageIndex0 == 0){
										_this.approachData = []
								}else{
									_this.loadingText = "没有更多了..."
								}
								break;
								case  1 :
								if(_this.pageIndex1 == 0){
										_this.mettingData = []
								}else{
									_this.loadingText = "没有更多了..."
								}
								break;
								case  2 :
								if(_this.pageIndex2 == 0){
								 _this.serviceData = []
								}else{
									_this.loadingText = "没有更多了..."
								}

								break;
								case  3 :
								if(_this.pageIndex3 == 0){
								_this.finishData = []
								}else{
									_this.loadingText = "没有更多了..."
								}
								break;
							}
							uni.hideLoading();
						}
					} else {
						uni.hideLoading();
						uni.showModal({
							title: '温馨提示',
							content: resJson.msg,
							showCancel: false
						})
						// .then(()=>{
						// 	if(resJson.msg.indexOf("对不起，你当前不是销售代表无法处理相关业务，请与管理员联系!")>=0){
						// 		uni.navigateTo({
						// 			url: '../userBind/userBind'
						// 		});
						// 	}
						// })
					}
			},
			do_goNext() { //扫码进场
			_this.isShowPicker = false
			let item = _this.city.value +_this.inputValue;
			_this.carReadResult = item;
			console.log("检测车牌号",item);
				if (!_this.checkVehiclePlateNo(item)) {
					uni.showModal({
						title: '温馨提示',
						content: '尊敬的用户，您输入车牌号有误，请重新输入！',
						showCancel: false
					});
					_this.carReadResult = '';
					_this.inputValue = ""
					return;
				} else {
					// _this.doCarEntry_Hand()
					uni.showModal({
						title: '温馨提示',
						content: '请确认是否前往接待！',
						success: res => {
							if (res.confirm) {
								//_this.doCarEntry_Hand()
								uni.navigateTo({
									url: '../home_approach_form/home_approach_form?carNO=' + _this.carReadResult
								});
							}
						},
					});
				}
			},
			doCarEntry_Hand() { //扫描车牌进场
				_this.$ZcPublic.Server.Post({
					IsNeedLogin: true,
					Paras: {
						Name: 'Uni_Partner_Detail',
						Action: 'doCarEntry_Hand',
						Data: {
							CarPlate: _this.carReadResult
						}
					},
					Callback: _this.cb_doCarEntry_Hand,
					Scope: _this
				})
			},
			cb_doCarEntry_Hand(resJson, scope) {
					console.log("车辆进场结果", resJson)
					if (resJson.success) {
						_this.selectIndex = 0
						_this.carReadResult = '';
						_this.inputValue = ''
						_this.QueryEntryCarList(_this.selectIndex,0,0);
						_this.getSaleManHome();
					} else {
						uni.showModal({
							title: '温馨提示',
							content: resJson.msg,
							showCancel: false
						})
					}
			},
			getSaleManLineOn() { //上班业务信息doCarEntry_Hand
				_this.$ZcPublic.Server.Post({
					IsNeedLogin: true,
					Paras: {
						Name: 'Uni_Partner_Detail',
						Action: 'getSaleManLineOn',
						Data: {}
					},
					Callback: _this.cb_getSaleManLineOn,
					Scope: _this
				})
			},
			cb_getSaleManLineOn(resJson, scope) {
				if (resJson.state == "back") {
					console.log("业务状态", resJson)
					if (resJson.success) {
						// _this.workStatus = "已上班";
						_this.saleData = resJson.data;
						if(_this.saleData){
							_this.saleData.LineOnDate = _this.$ZcPublic.formatDate(_this.saleData.LineOnDate,"yyyy-MM-dd")
						}
					} else {
						uni.showModal({
							title: '温馨提示',
							content: resJson.msg,
							showCancel: false
						})
						// .then(()=>{
						// 	if(resJson.msg.indexOf("对不起，你当前不是销售代表无法处理相关业务，请与管理员联系!")>=0){
						// 		uni.navigateTo({
						// 			url: '../userBind/userBind'
						// 		});
						// 	}
						// })
					}
				}
			},
			doSaleManLineOn() { //上班打卡 
				_this.$ZcPublic.Server.Post({
					IsNeedLogin: false,
					Paras: {
						Name: 'Uni_Partner_Detail',
						Action: 'doSaleManLineOn',
						Data: {}
					},
					Callback: _this.cb_doSaleManLineOn,
					Scope: _this
				})
			},
			cb_doSaleManLineOn(resJson, scope) {
					console.log("打卡状态", resJson)
					if (resJson.success) {
						_this.workStatus = "已上班";
					} else {
						uni.showModal({
							title: '温馨提示',
							content: resJson.msg,
							showCancel: false
						})
					}
			},
			doSaleManLineOff() { //下班打卡 
				_this.$ZcPublic.Server.Post({
					IsNeedLogin: true,
					Paras: {
						Name: 'Uni_Partner_Detail',
						Action: 'doSaleManLineOff',
						Data: {}
					},
					Callback: _this.cb_doSaleManLineOff,
					Scope: _this
				})
			},
			cb_doSaleManLineOff(resJson, scope) {
					console.log("下班打卡状态", resJson)
					if (resJson.success) {
						_this.workStatus = "上班";
					} else {
							uni.showModal({
							title: '温馨提示',
							content: resJson.msg,
							showCancel: false
						})
					}
			},
			getSaleManHome() { //首页导航选项卡数据
				_this.$ZcPublic.Server.Post({
					IsNeedLogin: false,
					Paras: {
						Name: 'Uni_Partner_Detail',
						Action: 'getSaleManHome',
						Data: {}
					},
					Callback: _this.cb_getSaleManHome,
					Scope: _this
				})
			},
			cb_getSaleManHome(resJson, scope) {
					console.log("首页导航数据", resJson);
					if (resJson.success) {
						_this.tabInfo[0].number = resJson.data.ShopOrganData.EntryNumber
						_this.tabInfo[1].number = resJson.data.ShopOrganData.WaitNumber
						_this.tabInfo[2].number = resJson.data.ShopOrganData.WorkingNumber
						_this.tabInfo[3].number = resJson.data.ShopOrganData.FinishNumber
						_this.tabInfo[1].numberClose = resJson.data.ShopOrganData.CancleNumber
						_this.ShopOrganName = resJson.data.ShopOrganName
						if (resJson.data.WorkState.indexOf("下班") >= 0) {
							_this.workStatus = "上班";
							_this.clockShow = true
						} else {
							_this.workStatus = "已上班";
						}
					} else {
						uni.showModal({
							title: '温馨提示',
							content: resJson.msg,
							showCancel: false
						})
						// .then(()=>{
						// 	if(resJson.msg.indexOf("对不起，你当前不是销售代表无法处理相关业务，请与管理员联系!")>=0){
						// 		uni.navigateTo({
						// 			url: '../userBind/userBind'
						// 		});
						// 	}
						// })
					}
			},
			do_clockShow() { //打卡显示
				_this.clockShow = true;
				_this.getSaleManLineOn();
			},
			do_clockIn(item) { //确定打卡
				_this.clockShow = false
				if (_this.workStatus == "上班") { //未上班状态
					if (item) {
						_this.doSaleManLineOn() //上班打卡
					} else {
						console.log("上班取消");
					}
				} else { //已经上班状态
					if (item) {
						_this.doSaleManLineOff() //下班打卡
					} else {
						console.log("下班取消");
					}
				}
			},
			do_selectTab(index) {
				uni.showLoading({
						title: '加载中',
						mask: true
					});
				_this.selectIndex = index;
				_this.carReadResult = '';
				_this.inputValue = '';
				switch(index){
					case 0:
					_this.pageIndex0 = 0;
					break;
					case 1:
					_this.pageIndex1 = 0;
					break;
					case 2:
					_this.pageIndex2 = 0;
					break;
					case 3:
					_this.pageIndex3 = 0;
					break;
				}
				let _indexData={
					0:_this.pageIndex0,
					1:_this.pageIndex1,
					2:_this.pageIndex2,
					3:_this.pageIndex3
				}
			// if(_indexData[index].length>0){
			// 	_this.loadingText = "没有跟多了...";
			// 	return
			// }else{
				_this.loadingText = "";
				_this.QueryEntryCarList(index,_indexData[index])
			// }

			},
			do_meeting(item) { //进场里面接待按钮CarPlate
				console.log("接待", item);
				uni.navigateTo({
					url: '../home_approach_form/home_approach_form?SN=' + item.CarSN+"&carNO="+item.CarPlate
				});
			},
			do_metSubmit(item) { //接待里面按钮
			console.log("进入下一页",item);
				if (item.State == '待开单1') {
					console.log("终止");
				} else if (item.State == '待开单2') {
					console.log("交车");

				} else if (item.State == '待开单'||"已开单") {
					uni.navigateTo({
						url: '../home_mitting_service/home_mitting_service?SN=' + item.CarSN + "&type=metting&VehicleInfoSN=" + item.VehicleInfoSN
					});
				}
				else if(item.State == '已完工'){
					uni.showToast({
						title: '已完工不能再开单',
						icon:'none'
					});
				}
			},
			do_service(item, status) { //服务里面按钮
				if (status == 'over') {
					uni.showModal({
						title: '温馨提示',
						content: '是否确定终止！',
						success: res => {
							if (res.confirm) {
								_this.doCancel_Repair(item.CarSN)
							}
						},
					});
				} else if (status == 'up') {
					console.log("交车");
					uni.showModal({
						title: '温馨提示',
						content: '是否交车！',
						success: res => {
							if (res.confirm) {
								_this.doFinish_Repair(item.CarSN)
							}
						},
					});
				} else if (status == "goNext") {
					uni.navigateTo({
						url: '../home_mitting_service/home_mitting_service?SN=' + item.CarSN + "&type=service&VehicleInfoSN=" + item.VehicleInfoSN
					});
				}
			},
			do_finish() { //交车

			},
			swiperChange(e) {
				console.log(e);
			},
			scan(item) { //扫一扫
				if (item == "ticket") {
					uni.scanCode({
						success: (res) => {
							console.log(res)
							_this.scanResult = res.result
						}
					});
				} else if (item == "car") { //车牌识别
					uni.chooseImage({
						count: 1,
						sizeType: ['original', 'compressed'],
						sourceType: ['camera', 'album'],
						success(res) {
							// 上传到服务器
							let upUrl = _this.$ZcPublic.CarUrl + 'PageService/doCheckUpCar.ashx?typeId=19&keyId=' + _this.$ZcPublic.CarKey;
							// console.log('upUrl',upUrl);
							uni.showLoading({
								title: '车辆识别中！',
								mask: true
							});
							uni.uploadFile({
								url: upUrl,
								filePath: res.tempFilePaths[0],
								name: 'imgFile',
								success(res) {
									uni.hideLoading()
									console.log('上传回调 = ', res);
									if (res.statusCode == 200) {
										let plate = JSON.parse(res.data)
										if (plate.success) {
											// _this.carReadResult = plate.data.CarPlate;
											_this.city.value = plate.data.CarPlate.substring(0,1);
											_this.inputValue = plate.data.CarPlate.substring(1);
											console.log("上传回调车牌_this.inputValue",_this.inputValue);
										} else {
											uni.showModal({
												title: '温馨提示',
												content: plate.msg,
												showCancel: false
											})
										}
									} else {
										uni.showModal({
											title: '温馨提示',
											content: "车牌识别失败！",
											showCancel: false
										})
									}
								}
							})
						}
					})
				}
			},
			checkNo(item) {
				_this.carReadResult = _this.carReadResult.toUpperCase()
			},
			checkVehiclePlateNo(item) {
				return RegExp(
					/^(([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z](([0-9]{5}[DF])|([DF]([A-HJ-NP-Z0-9])[0-9]{4})))|([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z][A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳使领]))$/
				).test(item);
			},
			scrolltoupper(e) {
				_this.linkShow = true
			},
			scrolltolower(e) { //监听滚动到底部显示链接图片
				if (e.detail.scrollTop > 10) {
					_this.linkShow = false
				} else {
					_this.linkShow = true
				}
			}
		}
	}
</script>

<style>
	/* 每个组件选项卡列表公共样式开始 */
	.list-box {
		padding: 30upx 30upx 30upx 30upx;
		margin: 5upx 16upx 25upx 16upx;
		box-shadow: 1upx 1upx 5upx 5upx #DAECFB;
		border-radius: 10upx;
		color: #666;
	}

	.list-box .list-common view {
		line-height: 40upx;
	}
.list-common>view{
	font-size: 26upx;
}
.list-common>view:nth-of-type(2){
	margin-top: 5upx;
}
	.list-box .list-common>.title,.title-text {
		font-size: 34upx;
		height: 45upx;
		line-height: 45upx;
		font-weight: 400;
		color: #333;
	}

	.list-bottom {
		height: 70upx;
		line-height: 90upx;
		border-top: 1upx dashed #E4F2FE;
		margin-top: 20upx;
	}

	.common-btn {
		background-color: #50ADFD !important;
		color: #fff;
		border-radius: 10upx !important;
		line-height: 40upx;
		padding: 10upx 27upx;
		font-size: 28upx;
		box-sizing: border-box;
		margin-left: 20upx;
	}
	.btn-grey {
		background-color: #999999 !important;
	}
	.space {
		color: #333;
		font-size: 22upx;
		position: relative;
		top: 4upx;
		left: 15upx;
	}

	.icon-xunhuan1 {
		font-size: 36upx;
		margin-left: 15upx;
		color: #54AEFD;
		position: relative;
		top: -5upx
	}

	/* //公共样式结束 */
	.banner-wrap {
		height: 100upx;
		border: 1upx solid #ccc;
		padding: 0 20upx;
		color: #fff;
		background: url("") center center no-repeat;
		/* background: url("../../static/home/bg.png") center center no-repeat; */
		background-size: 100%;
	}
	.icon-right {
		margin-right: 30upx;
	}
	.content-box {
		padding-top: 20upx;
		background-color: #fff;
		border-radius: 10upx;
		box-shadow: 1upx 1upx 5upx 5upx #DAECFB;
		position: absolute;
		top: 104upx;
		bottom: 0;
		width: 100%;
	}

	.tab-bar {
		width: 100%;
	}
	.tab-info {
		margin-left: 10upx;
		border-radius: 10upx;
		padding: 0 20upx;
		height: 105upx;
		line-height: 105upx;
		background: url("../../static/home/jinchang.png") center;
		background-size: 100%;
		color: #9473D4;
		box-sizing: border-box;
	}

	.tab-info:nth-of-type(2) {
		background: url(../../static/home/jiedai.png) center;
		background-size: 100%;
		color: #D1A82F;
	}

	.tab-info:nth-of-type(3) {
		background: url(../../static/home/fuwuzhong.png) center;
		background-size: 100%;
		color: #3CB2D5;
	}

	.tab-info:last-child {
		margin-right: 10upx;
		background: url(../../static/home/yijiaoche.png) center;
		background-size: 100%;
		color: #41C1A5;
	}

	.tabColor1 {
		border: 6upx solid #ba96f7;
	}

	.tabColor2 {
		border: 6upx solid #ead078;
	}

	.tabColor3 {
		border: 6upx solid #7bd7f2;
	}

	.tabColor4 {
		border: 6upx solid #68e9ce;
	}

	.tab-number {
		font-size: 28upx !important;
		height: 40upx;
		line-height: 30upx;
		padding-left: 10upx;
	}

	.content-head {
		height: 100upx;
		line-height: 100upx;
		margin: 27upx 10upx 27upx 10upx;
		border-radius: 10upx;
		box-shadow: 1upx 1upx 5upx 5upx #DAECFB;

	}

	.swiper-box {
		position: absolute;
		top: 270upx;
		bottom: 0;
		width: 100%;
	}

	swiper {
		height: auto;
	}

	.scroll-view {
		/* padding-top: 20upx; */
		height: 100%;
	}

	.car-status>view {
		font-family: "Tahoma" !important;
		font-size: 38upx;
		transform: skew(-15deg);
		color: #F4B864;
		font-weight: 540;
	}

	.car-status>view:first-child {
		padding-left: 16upx;
		color: #4EADFB;
	}

	.car-status image {
		margin-left: 20upx;
		height: 45upx;
		width: 180upx;
	}

	.image-select {
		width: 160upx !important;
	}

	.icon-xiasanjiaoxiangxiamianxing:before {
		position: absolute;
		right: -30upx !important;
		font-size: 18upx !important;
		color: #fff;
		top: 9upx !important
	}

	.serach-add image {
		width: 55upx;
		height: 40upx;
		margin: 0 30upx 0 20upx;
	}

	.serach-add input,
	.add-input,.add-car-wrap {
		height: 70upx;
		line-height: 70upx;
		border: 1upx solid #e5e5e5;
		border-radius: 6upx;
		padding: 0 15upx;
	}

	.add-input-wrap .add-input {
		width: 100%;
		padding-right: 50upx;
	}

	.add-input-wrap {
		width: 60%;
		margin-right: 50upx;
	}

	.serach-add>view {
		flex: 0 0 125upx;
	}

	.serach-add>view button {
		background-color: #50ADFD;
		padding: 0 30upx;
		height: 60upx;
		line-height: 60upx;
		font-size: 28upx;

	}

.btn-add-wrap{
	flex: 0 0 130upx !important;
}
	.icon-sousuo1 {
		font-size: 42upx;
		position: absolute;
		right: 22upx;
		top: 3upx;
		color: #50ADFD;
	}

	.image {
		position: absolute;
		width: 16upx;
		height: 60upx;
		bottom: -42upx;
		z-index: 10;
		opacity: 0;
		transition: opacity 0.5s ease;
	}

	.image-link-left {
		left: 30upx;
	}

	.image-link-right {
		right: 30upx;
	}

	.imageShow {
		opacity: 1;
		transition: opacity 1s ease;
	}

	.icon-sousuo2 {
		margin: 0 10upx 0 30upx;
		font-size: 36upx;
	}

	.car-scan {
		font-size: 20upx;
		height: 30upx;
		line-height: 24upx;
		color: #7F7F7F;
	}
    
.input-placeholder{
			color:#999;
			font-size: 22upx;
}
/* 2018-11-29 新加展示线索详情 */
.show-detail-wrap{
	position: absolute;
	top:0;
	bottom: 0;
	width: 100%;
	background-color: rgba(0,0,0,.3);
	z-index: 9999;
}
.show-detail-info{
	width: 80%;
	min-height: 160upx;
	padding: 30upx 20upx;
	border-radius: 12upx;
	background-color: #fff;
	box-sizing: border-box;
}
.show-detail-info>view{
	min-height:60upx ;
	line-height: 60upx;
	align-items: center;
}
.add-search{
	border: 2upx solid #50ADFD !important;
	background-color: transparent !important;
	color:#50ADFD  !important;
	padding: 0 28upx !important;
}
.add-input2{
	border: none !important;
	
}
	.picker_view{
		width: 80upx !important;
		height: 70upx !important;
		position: relative;
		padding-right: 10upx;
		/* border-right: 1upx solid #e5e5e5; */
		position: relative;
	}
	.picker_view:before{
		position: absolute;
		content: '';
		width: 1upx ;
		height: 40upx;
		background-color: #e5e5e5;
		right: 0;
		top:15upx
	}
	.picker_view:after{
		content: '';
		position: absolute;
		width: 0;
		height: 0;
		border-width: 11upx 6upx 11upx;
		border-style: solid;
		border-color: #5d5d5d transparent transparent; /*灰 透明 透明 */
		right: 15upx;
		top: 30upx;
	 }
	 .add-car-wrap{
		 padding-left: 0 !important;
		 /* border: none !important; */
	 }
	 	/* 车牌号自定义选择键盘 */
		.add-carNO-choose{
			position: absolute;
			width: 100%;
			top:0;
			bottom: 0;
			background-color: rgba(0,0,0,0);
		}
	 .picker_mask{width: 100%;position: fixed;bottom: 0;left: 0;display: flex;align-items: center;justify-content: center;z-index: 1000;opacity: 0;transition: opacity .5s;}
	 .picker_content{height: 100%;width: 100%;background-color: #FFFFFF;bottom: -1000upx;;left: 0;position: absolute;transition: bottom .5s;}
	 .picker_box{height: 100%;width: 100%;overflow: auto;box-sizing: border-box;background-color: #E5E5E5;display: flex;flex-direction: column;}
	 .picker_item1>view{padding: 10upx 0;margin: 8upx;background-color: #CCCCCC;border-radius: 6upx;display: flex;align-items: center;justify-content: center;flex: 1;}
	 .picker_item1_hover{background-color: #FFFFFF!important;}
	 .picker_item2>view{padding: 10upx 0;margin: 6upx;background-color: #FFFFFF;border-radius: 6upx;display: flex;align-items: center;justify-content: center;flex: 1;box-sizing: border-box;}
	 .picker_item2_hover{background-color: #CCCCCC!important;}
	 
	 /* 车牌 软键盘 删除图标 */
	 .icon-delete:before{
	 	content: '\e623';
	 	font-size: 40upx;
	 }
</style>
